import xlrd
import datetime

#防止python两个浮点数相加发生小数循环
from decimal import Decimal

#年假基数,6个等级
holodayBase = {
    1: 6.64,
    2: 7.36,
    3: 8,
    4: 8.64,
    5: 9.36,
    6: 10,
}

def getExclusionList():
    try:
        wb = xlrd.open_workbook(r"D:\holidayFiles\exclusionList.xls")
    except Exception as e:
        raise e
    sh = wb.sheet_by_name('Sheet')
    global exclusionList
    exclusionList = []
    for i in range(1,sh.nrows):
        exclusionList.append(sh.cell(i,0).value)
    return exclusionList


def getHolidayBase(year):
    currentTime = datetime.datetime.now()
    currentYear = str(currentTime)[0:4]
    y = int(currentYear) - int(year[0:4]) + 1
    if y <= 6:
        return holodayBase[y]
    return 10


def holidayCalculator():
    try:
        wb = xlrd.open_workbook(r"D:\holidayFiles\holiday.xls")
    except Exception as e:
        raise e
    sh = wb.sheet_by_name("Sheet")
    # a = sh.cell_value(3, 4)
    for i in range(3, sh.nrows):
        data = sh.cell_value(i, 4)
        if data != '':
            holidayBase = getHolidayBase(data)
            holidayHour = sh.cell_value(i, 6)
            print(Decimal(str(holidayBase)) + Decimal(str(holidayHour)))




holidayCalculator()


